<template>
  <div class="my-conetent body-bg">
    <div v-if="!initLoading">
      <div class="top">
        <img class="bg-img" src="/static/images/my/bg.png" alt="bg">
        <p class="keyong">可用积分</p>
        <p class="keyong-total">6005</p>
        <p class="leiji">累计积分 12026  </p>
      </div>
      <div class="tabs-cont">
        <van-tabs sticky animated swipeable color="#00B7EE" lazy-render :active="active" @change="changeTabs">
          <van-tab title="收入">
            <scroll-view :scroll-y="true" :class="{scrollHeight: scrollHeight}" @scrolltolower="lower" :scroll-top="0">
              <ul class="list-cont" v-if="incomeList.length">
                <li class="items border-bottom" v-for="(item,index) in incomeList" :key="index">
                  <p class="title">{{item.title}} <br> <span class="date">{{item.date}}</span></p>
                  <p class="number">＋{{item.number}}</p>
                </li>
              </ul>
              <div v-else class="empty">
                <img src="/static/images/empty-icon.png" alt="空">
                <p class="empty-tips">暂无数据~</p>
              </div>
            </scroll-view>
          </van-tab>
          <van-tab title="兑换记录">
            <scroll-view :scroll-y="true" :class="{scrollHeight: scrollHeight}" @scrolltolower="lower2" :scroll-top="0">
              <ul class="list-cont" v-if="exchangeRecords.length">
                <li class="items border-bottom" v-for="(item,index) in exchangeRecords" :key="index">
                  <p class="title">{{item.title}} <br> <span class="date">{{item.date}}</span></p>
                  <p class="number">＋{{item.number}}</p>
                </li>
              </ul>
              <div v-else class="empty">
                <img src="/static/images/empty-icon.png" alt="空">
                <p class="empty-tips">暂无数据~</p>
              </div>
            </scroll-view>
          </van-tab>
        </van-tabs>
      </div>
    </div>
    <div v-else class="init-loading"><van-loading type="spinner" color="#1989fa" /></div>
  </div>
</template>

<script>
import store from '../../store/globalStore'
export default {
  data() {
    return {
      scrollHeight: true,
      initLoading: true, // 初始加载
      active: 0,
      incomeList: [
        {title: "足球基础训练班课程", date: "2018-11-07 18:00", number: "100"},
        {title: "足球基础训练班课程", date: "2018-11-07 18:00", number: "100"},
        {title: "足球基础训练班课程", date: "2018-11-07 18:00", number: "100"},
        {title: "足球基础训练班课程", date: "2018-11-07 18:00", number: "100"},
        {title: "足球基础训练班课程", date: "2018-11-07 18:00", number: "100"},
        {title: "足球基础训练班课程", date: "2018-11-07 18:00", number: "100"},
      ],
      exchangeRecords: [
        {title: "足球基础训练班课程", date: "2018-11-07 18:00", number: "100"},
        {title: "足球基础训练班课程", date: "2018-11-07 18:00", number: "100"},
        {title: "足球基础训练班课程", date: "2018-11-07 18:00", number: "100"},
        {title: "足球基础训练班课程", date: "2018-11-07 18:00", number: "100"},
        {title: "足球基础训练班课程", date: "2018-11-07 18:00", number: "100"},
      ]
    };
  },
  onShow() {
    this.getShiftWorkList();
  },
  methods: {
    // 获取列表
    getShiftWorkList() {
      this.$fetch.shiftWork()
      .then(res=>{
        this.initLoading = false;
      }).catch(err=>{
        this.initLoading = false;
      })
    },
    // 切换tabs
    changeTabs(e) {
      this.active = e.mp.detail.index;
    },
    // lower
    lower() {
      console.log("9")
    },
    lower2() {
      console.log("8")
    }
  },
};
</script>
<style lang="less" scope>
.my-conetent {
  width: 100%;
  min-height: 100vh;
  overflow: hidden;
  .top{
    width: 100%;
    height: 190px;
    position: relative;
    color: #fff;
    z-index: 1;
    overflow: hidden;
    .bg-img{
      width: 100%;
      height: 190px;
      display: block;
      position: absolute;
      top: 0;
      left: 0;
      z-index: 0;
    }
    p{
      width: 100%;
      padding: 0 45px;
      box-sizing: border-box;
      position: relative;
      z-index: 2;
    }
    .keyong{
      font-size: 13px;
      margin-top: 35px;
    }
    .keyong-total{
      margin: 10px 0 22px 0;
      font-size: 36px;
      font-weight: bold;
    }
    .leiji{
      font-size: 13px;
    }
  }
  .tabs-cont{
    width: 100%;
    padding: 0 15px;
    box-sizing: border-box;
    position: relative;
    top: -18px;
    z-index: 3;
    .van-tab--active{
      .van-ellipsis{
        color: #00B7EE;
      }
    }
    .scrollHeight{
      height: 300px;
    }
    .van-sticky{
      border-bottom: 0.5px solid #dcdcdc;
    }
    .list-cont{
      width: 100%;
      background: #fff;
    }
    .empty{
      background: #fff;
    }
    .items{
      width: 100%;
      padding: 16px 22px;
      box-sizing: border-box;
      display: flex;
      justify-content: space-between;
      align-items: center;
      .title{
        font-size: 14px;
        color: #333;
        .date{
          font-size: 12px;
          color: #999;
          margin-top: 6px;
          display: inline-block;
        }
      }
      .number{
        font-size: 14px;
        color: #FD1200;
        font-weight: bold;
      }
    }
  }
}
</style>
